<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>${name_china}管理列表</title>
<%@include file="/common/head.jsp" %>

<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
        </div>
    </div>
    <div class="page-title-border"></div>
</div>
<div class="search-field">
    <span class="field-cont">
        <span class="field-cont-title">推广位ID: ${tgw}  ${userNickName}</span>
    </span>
   <span class="field-cont">
        <span class="field-cont-title">手机号:13752222222</span>
   </span>
   <span class="field-cont" id="toolbar">
   	
   </span>
    <span class="field-cont">
        <span class="field-cont-title">
        <a id="goBack" class="distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a></span>
    </span>
</div>
<div class="search-field">
    <span class="field-cont">
        <span class="field-cont-title">累计订单:${orderCount}</span>
        
    </span>
   <span class="field-cont">
        <span class="field-cont-title">有效累计订单:${totalMoney}</span>
   </span>
    
    <span class="field-cont">
        <span class="field-cont-title">累计总额:${effectOrderCount}</span>
    </span>
    <span class="field-cont">
        <span class="field-cont-title">累计建群数:${groupCount}</span>
    </span>
</div>

<div class="search-field">
    <div class="fildrange">
			<span class="field-cont"> <span class="field-cont-title">上架时间</span>
				<input type="text" id="startTime" name="startTime" class="summer-input summer-validatebox"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/>
			</span> 
			<span class="field-cont"> <span class="field-cont-title">至</span>
				<input type="text" id="endTime" name="endTime" class="summer-input summer-validatebox"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/>
			</span>
		</div>
    <span class="field-cont">
        <span class="field-cont-title">订单数></span>
         <input type="text" class="summer-input" id="orderCount"/>
    </span>
    <span class="field-cont">
        <span class="field-cont-title">总额></span>
         <input type="text" class="summer-input" id="totalMoney"/>
    </span>
     <span class="field-cont">
        <span class="field-cont-title">群数></span>
         <input type="text" class="summer-input" id="groupCount"/>
    </span>
    <span class="field-btn-wrapper">
        <a id="search" class="btn btn-primary btn-icon wave distance-right"><i class="icon icon-search"></i></a>
        <a id="reset" class="btn btn-icon wave wave-dark"><i class="icon icon-refresh"></i></a>
    </span>
</div>
<div id="t-wrap">
    <table class="summer-datagrid" id="dataList">
	    <col width="40%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <thead>
		    <tr>
		        <th>时间</th>
				<th>订单数</th>
		        <th>有效订单数</th>
		        <th>金额</th>
		        <th>建群数</th>
		    </tr>
	    </thead>
    </table>
</div>

<script>
	//请求url
	var CONST_URL = {
		LIST: basePath + '${common_url}list',
		TGW_PERFORM_LIST : basePath + '${common_url}userTgw/perform/list',
		SET_TGW_VIEW :basePath + "${common_url}setTGWView?userId=${userId}&groupId=${groupId}",
		TGW_GROUP : basePath + "${common_url}tgwGroupView?userId=${userId}&groupId=${groupId}&tgwId=${id}&phone=${phone}"
	
	};
	
    var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
        // 新建toobar
		$.funcbar({
			id: 'toolbar',
			type: 'toolbar',
			data: permission,
			permit: ['${name_english}:tgwGroup'],
		});
        
        // 查询按钮
        $('#search').on('click', reloadTable);
        
        //重置按钮
        $('#reset').on('click', function () {
        	//重置文本框的值
        	$('#${name_english}Version').val('');
        	$('#startTime').val(''); 
        	$('#stopTime').val('');
        	reloadTable();
        });
        createTable();
        $('#backBtn,#goBack').on('click',backMain);
      	//新建
        $('#toolbar').on('click', 'a[data-permit="${name_english}:tgwGroup"]', function() {
        	
        	window.location.href = CONST_URL.TGW_GROUP; 	  	
		});
      
    });
    function backMain() {
    	window.location.href = CONST_URL.SET_TGW_VIEW;
    }
    // 重新加载表格
	function reloadTable() {
		$('#dataList').datagrid('reload',{
            ajax: {
            	param: {
            		"startTime": $('#startTime').val(),
                	"endTime": $('#endTime').val(),
                	"orderCount": trimSpace($('#orderCount').val()),
                	"money": trimSpace($('#totalMoney').val()),
                	"groupCount": trimSpace($('#groupCount').val())
            	}
            }
        });
	}
    
    //创建表格
    function createTable() {
    	$('#dataList').datagrid({
    		ajax: {
    			url: CONST_URL.TGW_PERFORM_LIST,
    			param: {
    				"id": ${id}, 
                	"startTime": trimSpace($('#startTime').val()),
                	"endTime": trimSpace($('#endTime').val()),
                	"orderCount": trimSpace($('#orderCount').val()),
                	"money": trimSpace($('#totalMoney').val()),
                	"groupCount": trimSpace($('#groupCount').val())
            	
    			} 
    		},
    		columns: [
    		     {
    		    	 field: 'time',
    		     },
    		     {
    		    	 field: 'orderCount'
    		     },{
    		    	 field: 'effectOrderCount'
    		     },{
    		    	 field: 'money'
    		     },{
    		    	 field: 'groupCount'
    		     }
    	    ]
    	});
    }
</script>
</body>
</html>